<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:pe="http://primefaces.org/ui/extensions">

    <ui:composition>

        <p:dialog id="dlgOperacaoNegocial"
                  header="Operação Negocial"
                  widgetVar="dialogOperacaoNegocial" 
                  modal="true" 
                  resizable="false" 
                  appendTo="@(body)">

            <h:form id="formOperacaoNegocial" >

                <h:panelGrid id="displayOperacaoNegocial" >

                    <h:panelGroup>

                        <h:outputText value="Tipo de Operação" /><br/>
                        <p:selectOneMenu value="#{operacaoNegocialBean.selected.tipoOperacaoNegocial}" 
                                         style="width: 300px; text-transform: uppercase"
                                         required="true"
                                         requiredMessage="Campo tipo de operação requerido"
                                         styleClass="up"
                                         >

                            <f:selectItem itemLabel="Selecione" />
                            <f:selectItems value="#{operacaoNegocialBean.tiposOperacoesNegociais}" />
                            <f:converter converterId="simpleEntityConverter" />

                        </p:selectOneMenu><br/>

                    </h:panelGroup>

                    <h:panelGroup>

                        <h:panelGrid style="width: 100%"
                                     columns="2">

                            <h:panelGroup>

                                <h:outputText value="Cliente" /><br/>
                                <p:autoComplete id="completeCliente"
                                                value="#{operacaoNegocialBean.selected.cliente}" 
                                                completeMethod="#{operacaoNegocialBean.completeClientes}"  
                                                var="cliente" 
                                                itemLabel="#{cliente}"
                                                itemValue="#{cliente}" 
                                                converter="simpleEntityConverter" 
                                                forceSelection="true"
                                                styleClass="up"
                                                minQueryLength="4"
                                                required="true"
                                                requiredMessage="Campo cliente requerido">

                                    <p:column >  
                                        #{cliente} 
                                    </p:column>

                                </p:autoComplete>

                            </h:panelGroup>

                            <h:panelGroup>

                                <div align="right">
                                    <br/>

                                    <p:commandButton icon="ui-icon-plus"
                                                     style="width: 80%;"
                                                     actionListener="#{clienteBean.prepareCreate}" 
                                                     update=":formCliente"
                                                     oncomplete="dialogCliente.show()"/>
                                </div>

                            </h:panelGroup>


                        </h:panelGrid>

                    </h:panelGroup>

                    <h:panelGroup>

                        <h:outputText value="Data Entrega (Loteria)" /><br/>
                        <p:inputMask value="#{operacaoNegocialBean.selected.dataEntregaLoteria}" 
                                     style="width: 97%" 
                                     mask="99/99/9999" 
                                     required="true"
                                     requiredMessage="Campo data entrega (loteria) é requerido">

                            <f:convertDateTime timeZone="America/Sao_Paulo"/>

                        </p:inputMask><br/>

                    </h:panelGroup>

                    <h:panelGroup>

                        <h:outputText value="Data Entrega (Caixa)" /><br/>
                        <p:inputMask value="#{operacaoNegocialBean.selected.dataEntregaCaixa}" 
                                     style="width: 97%" 
                                     mask="99/99/9999" 
                                     required="true"
                                     requiredMessage="Campo data entrega (caixa) é requerido">

                            <f:convertDateTime timeZone="America/Sao_Paulo"/>

                        </p:inputMask><br/>

                    </h:panelGroup>

                    <h:panelGroup>

                        <h:outputText value="Valor Total" /><br/>
                        <pe:inputNumber value="#{operacaoNegocialBean.selected.valorTotal}" 
                                        style="width: 97%" 
                                        required="true"
                                        requiredMessage="Campo valor total é requerido"
                                        decimalSeparator=","
                                        thousandSeparator="."
                                        symbol="R$"/>

                    </h:panelGroup>

                    <h:panelGroup>

                        <h:outputText value="Valor Comissão" /><br/>
                        <pe:inputNumber value="#{operacaoNegocialBean.selected.valorComissao}" 
                                        style="width: 97%" 
                                        required="true"
                                        requiredMessage="Campo valor comissão é requerido"
                                        decimalSeparator=","
                                        thousandSeparator="."
                                        symbol="R$"/>

                    </h:panelGroup>

                    <h:panelGroup>

                        <h:outputText value="Observações" /><br/>
                        <p:inputTextarea value="#{operacaoNegocialBean.selected.observacoes}" 
                                         style="width: 97%; text-transform: uppercase" 
                                         />

                    </h:panelGroup>

                </h:panelGrid>


                <hr/>

                <p:commandButton value="Gravar" 
                                 actionListener="#{operacaoNegocialBean.save(event)}"
                                 update=":formOperacoesNegociais:dtOperacoesNegociais, :growl, displayOperacaoNegocial"
                                 oncomplete="handleSubmit(xhr,status,args,dialogOperacaoNegocial);"
                                 />

            </h:form>

        </p:dialog>

    </ui:composition>

</html>


